﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data.SqlClient;
using System.Data.Common;

namespace BOMS.Utility
{
    /// <summary>
    /// 扩展方法
    /// </summary>
    public static class Extension
    {
        /// <summary>
        /// 将DbParameter转为SqlParameter
        /// </summary>
        /// <param name="Params"></param>
        /// <returns></returns>
        public static SqlParameter[] ToSqlParameters(this DbParameter[] Params)
        {
            if (Params != null)
            {
                int L = Params.Length;
                SqlParameter[] SqlParams = new SqlParameter[L];
                for (int i = 0; i < Params.Length; i++)
                {
                    SqlParams[i] = (SqlParameter)Params[i];
                }
                return SqlParams;
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 将DbParameter转为SqlParameter
        /// </summary>
        /// <param name="Params"></param>
        /// <returns></returns>
        public static MySqlParameter[] ToMySqlParameters(this DbParameter[] Params)
        {
            if (Params != null)
            {
                int L = Params.Length;
                MySqlParameter[] SqlParams = new MySqlParameter[L];
                for (int i = 0; i < Params.Length; i++)
                {
                    SqlParams[i] = (MySqlParameter)Params[i];
                }
                return SqlParams;
            }
            else
            {
                return null;
            }
        }

    }
}
